package com.reny.ll.git.core

import android.app.Application
import com.reny.ll.git.core.taskdispatch.TaskDispatcher
import com.reny.ll.git.core.taskdispatch.task.Task


object App {
    lateinit var instance: Application
    @JvmField
    var isDebug: Boolean = false
    @JvmField
    var APPLICATION_ID:String = ""
    @JvmField
    var VERSION_NAME:String = ""
    @JvmField
    var VERSION_CODE:Int = 1
    @JvmField
    var APP_NAME = ""
    @JvmField
    var CHANNEL:String? = null

    @JvmField
    var deviceId:String? = null
}

fun Application.initBase(vararg tasks: Task?) {
    App.instance = this

    TaskDispatcher.init(this)
    var dispatcher = TaskDispatcher.createInstance()
    tasks.forEach {
        it?.let { task ->
            dispatcher = dispatcher.addTask(task)
        }
    }
    dispatcher.start()
    dispatcher.await()

    LifecycleUtils.init(this)
}